const { app, BrowserWindow } = require('electron');

function createWindow () {
  const win = new BrowserWindow({
    width: 1024,
    height: 768,
    webPreferences: {
      nodeIntegration: false, // 关闭 Node 集成，保证 Web Bluetooth 可用
      contextIsolation: true, // 推荐
    }
  });

  // 支持通过命令行参数传递 URL
  const urlArg = process.argv.find(arg => arg.startsWith('--url='));
  if (urlArg) {
    win.loadURL(urlArg.replace('--url=', ''));
  } else {
    win.loadFile('/main.html');
  }
}

app.whenReady().then(createWindow);